home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / source / demostuf / zlogo1.pas < prev    next >
Pascal/Delphi Source File  |  1994-07-25  |  3KB  |  213 lines

  1. program logo1;
  2. {
  3.     Zoom Logo #1
  4.     - by Bjarke Viksφe
  5.     mar 1994
  6.  
  7.   THIS PROGRAM WAS CODED BY BJARKE VIKS0E.
  8.   YOU ARE FREE TO DO WHATEVER YOU WANT WITH THIS PIECE OF CODE.
  9.   E-MAIL ME AT: dat92230@rix02.lyngbyes.dk IN 1994 FOR CHAT AND CODE.
  10.  
  11.     Zooming is pretty easy. Zoom positions are precalc'ed, some may complain
  12.     about this - array look-ups takes longer time the real-time calc'ing.
  13.     Uses my generic 'calc middle-values' routine which has proved pretty
  14.     handy. Called calc-slope.
  15. }
  16.  
  17. (*{$DEFINE DEBUG}*)
  18.  
  19. uses
  20.     DEMOINIT,ILBM256;
  21.  
  22. type
  23.     SlopeArray = array[0..320] of integer;
  24.  
  25. var
  26.     buffer,tempscreen : pScreen;
  27.     slope : SlopeArray;
  28.     otherslope : SlopeArray;
  29.     y320tabel : array[0..HEIGHT] of word;
  30.  
  31.     xpos,ypos,xsize,ysize : integer;
  32.  
  33. const
  34.     display1 : integer = $0000;
  35.     display2 : integer = $4000;
  36.  
  37.  
  38. (*------------------------------------------------*)
  39.  
  40. procedure InitDemo;
  41. var
  42.     i : integer;
  43. begin
  44.     Screen_Off;
  45.     FadeCMAP(0);
  46.     ClearWholeScreen;
  47.  
  48.     xsize:=120;
  49.     ysize:=2;
  50.     xpos:=160-(xsize DIV 2);
  51.     ypos:=100-(ysize DIV 2);
  52.  
  53.     for i:=0 to HEIGHT do y320tabel[i]:=i*320;
  54.  
  55.     new(buffer);
  56.     new(tempscreen);
  57.     LoadPix(buffer,'PARASIT1.LBM');
  58.     MakeTweak(buffer,tempscreen);
  59.     SetCMAP;
  60.     Screen_On;
  61. end;
  62.  
  63. procedure UninitDemo;
  64. var
  65.     i : integer;
  66. begin
  67.     dispose(buffer);
  68.     dispose(tempscreen);
  69. end;
  70.  
  71.  
  72. (*------------------------------------------------*)
  73.  
  74. procedure SwapDisplay;
  75. var
  76.     temp : word;
  77. begin
  78.     temp:=display2;
  79.     display2:=display1;
  80.     display1:=temp;
  81.     SetAddress(Ptr(SEGA000,display2));
  82. end;
  83.  
  84.  
  85. (*------------------------------------------------*)
  86.  
  87. procedure CalcSlope(x1,x2,ysize : integer); assembler;
  88. asm
  89.     lea    si,slope
  90.     mov    ax,x1
  91.     mov    cx,x2
  92.     mov    dx,ysize
  93.  
  94.     push    ax
  95.     sub    cx,ax
  96.     inc    cx
  97.  
  98.     and    dx,dx
  99.     jz        @zero
  100.  
  101.     cmp    dx,1
  102.     jne    @not1
  103.     dec    cx
  104.     mov    dx,cx
  105.     xor    ax,ax
  106.     jmp    @one
  107. @not1:
  108.     cmp    dx,2
  109.     jne    @not2
  110.     mov    ax,$7FFF
  111.     imul    cx
  112.     jmp    @one
  113. @not2:
  114.  
  115.     mov    dx,$0001
  116.     mov    ax,$0000
  117.     idiv    ysize
  118.     imul    cx
  119. @one:
  120.     pop    cx
  121.     xor    bx,bx
  122.  
  123.     inc    ysize
  124. @loop:
  125.     mov    [si],cx
  126.     add    si,2
  127.     add    bx,ax
  128.     adc    cx,dx
  129.     dec    ysize
  130.     jnz    @loop
  131. @zero:
  132. end;
  133.  
  134.  
  135. (*------------------------------------------------*)
  136.  
  137. procedure ZoomLine(xpos,ysize,dst_offset : word); assembler;
  138. asm
  139.     push    ds
  140.     mov    es,SEGA000
  141.     mov    di,dst_offset
  142.     add    di,display1
  143.     mov    ax,WORD PTR buffer+2
  144.     DB $8E,$E0    {mov fs,ax}
  145.     mov    dx,xpos
  146.     add    dx,WORD PTR buffer
  147.     lea    si,slope
  148.     mov    cx,ysize
  149.     cld
  150. @yloop:
  151.     lodsw
  152.     add    ax,dx
  153.     mov    bx,ax
  154.     DB $64        {FS: prefix}
  155.     mov    al,[bx]
  156.     mov    [es:di],al
  157.     add    di,WIDTH
  158.     loop    @yloop
  159.     pop    ds
  160. end;
  161.  
  162.  
  163. (*------------------------------------------------*)
  164.  
  165.  
  166. procedure RunOnce;
  167. var
  168.     i,j : integer;
  169.     dst_offset : word;
  170. begin
  171.     SwapDisplay;
  172.     VBLANK;
  173. {$IFDEF DEBUG}
  174.     SetRGB(0,30,0,0);
  175. {$ENDIF}
  176.  
  177.     CalcSlope(0,319,xsize);
  178.     otherslope:=slope;
  179.     CalcSlope(0,199,ysize);
  180.     for i:=0 to ysize do slope[i]:=y320tabel[slope[i]];
  181.  
  182.     j:=0;
  183.     dst_offset:=(ypos*WIDTH)+(xpos shr 2);
  184.     for i:=xpos to xpos+xsize do begin
  185.         SetBitplanes(1 shl (i AND 3));
  186.         ZoomLine(otherslope[j],ysize,dst_offset);
  187.         inc(j);
  188.         if ((i AND 3)=3) then inc(dst_offset);
  189.     end;
  190.  
  191.     if (xpos>0) AND (ypos>0) then begin
  192.         dec(xpos);
  193.         dec(ypos);
  194.         inc(xsize,2);
  195.         inc(ysize,2);
  196.     end;
  197.  
  198. {$IFDEF DEBUG}
  199.     SetRGB(0,0,0,0);
  200. {$ENDIF}
  201. end;
  202.  
  203.  
  204. begin
  205.     OpenScreen;
  206.     InitDemo;
  207.     repeat RunOnce until KeyPressed;
  208.     UninitDemo;
  209.     CloseScreen;
  210.     writeln;
  211.     writeln('A small piece of code by Bjarke Viksφe...');
  212. end.
  213.